package com.dily.study.demo.service;

import com.dily.study.demo.entity.jpa.Student;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;

/**
 * Date: 2022-05-05 星期四
 * Time: 15:55
 * Author: Dily_Su
 * Remark:
 * redis 使用
 */
@Service
public class RedisDemoService {

    @Autowired
    private RedisTemplate<Object, Object> redisTemplate;

    public void test() {
        Student dily = new Student();
        dily.setName("dily");
        dily.setSex("men");
        redisTemplate.opsForValue().set("dily", dily);
        Student student = (Student) redisTemplate.opsForValue().get("dily");
        System.out.println(student);
    }
}
